<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\WishWheel;

class WishWheelController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new WishWheel();
    }

    //许愿转盘设置单次抽奖消耗数量
    public function wishWheelSetNeedNum(Request $request){
        $res = $this->model->wishWheelSetNeedNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘设置单次抽奖消耗数量');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘设置档位抽取次数
    public function wishWheelSetDrawNum(Request $request){
        $res = $this->model->wishWheelSetDrawNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘设置档位抽取次数');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘设置奖池开启/关闭
    public function wishWheelSetPoolStatus(Request $request){
        $res = $this->model->wishWheelSetPoolStatus($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘设置奖池开启/关闭');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘保存奖池配置
    public function wishWheelSavePoolConfig(Request $request){
        $res = $this->model->wishWheelSavePoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘保存奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增奖池
    public function wishWheelAddPool(Request $request){
        $res = $this->model->wishWheelAddPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘编辑奖池
    public function wishWheelEditPool(Request $request){
        $res = $this->model->wishWheelEditPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘编辑奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池设置礼物调整
    public function wishWheelPoolSetGiftAdjust(Request $request){
        $res = $this->model->wishWheelPoolSetGiftAdjust($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘奖池设置礼物调整');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘更新奖池缓存
    public function wishWheelPoolReset(Request $request){
        $res = $this->model->wishWheelPoolReset($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘更新奖池缓存');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池列表
    public function wishWheelPoolList(Request $request){
        $res = $this->model->wishWheelPoolList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘配置信息
    public function wishWheelConfig(Request $request){
        $res = $this->model->wishWheelConfig($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池配置列表
    public function wishWheelPoolConfigList(Request $request){
        $res = $this->model->wishWheelPoolConfigList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池配置剩余数量
    public function wishWheelPoolConfigNum(Request $request){
        $res = $this->model->wishWheelPoolConfigNum($request->all());
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增白名单
    public function wishWheelAddWhite(Request $request){
        $res = $this->model->wishWheelAddWhite($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘删除白名单
    public function wishWheelDelWhite(Request $request){
        $res = $this->model->wishWheelDelWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘删除白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘白名单列表
    public function wishWheelWhiteList(Request $request){
        $res = $this->model->wishWheelWhiteList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽奖明细列表
    public function wishWheelDrawList(Request $request){
        $res = $this->model->wishWheelDrawList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽奖用户汇总数据
    public function wishWheelUserStatistic(Request $request){
        $res = $this->model->wishWheelUserStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽奖用户汇总数据(同设备)
    public function wishWheelUserStatisticChild(Request $request){
        $res = $this->model->wishWheelUserStatisticChild($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽奖每日统计
    public function wishWheelDayStatistic(Request $request){
        $res = $this->model->wishWheelDayStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增展示礼物
    public function wishWheelAddGift(Request $request){
        $res = $this->model->wishWheelAddGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘删除展示礼物
    public function wishWheelDelGift(Request $request){
        $res = $this->model->wishWheelDelGift($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘删除展示礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖品列表
    public function wishWheelGiftList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishWheelGiftList($request));
    }

    //许愿转盘新增个人池用户
    public function wishWheelAddPoolUser(Request $request){
        $res = $this->model->wishWheelAddPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增个人池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘删除个人池用户
    public function wishWheelDelPoolUser(Request $request){
        $res = $this->model->wishWheelDelPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘删除个人池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿池查看个人奖池剩余数
    public function wishWheelPoolSelfConfigNum(Request $request){
        $res = $this->model->wishWheelPoolSelfConfigNum($request->all());

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘个人池用户列表
    public function wishWheelPoolUserList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishWheelPoolUserList($request));
    }

    //许愿转盘奖池已配置礼物列表
    public function wishWheelPoolGift(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishWheelPoolGift($request));
    }

    //许愿转盘新增奖池白名单
    public function wishWheelAddPoolWhite(Request $request){
        $res = $this->model->wishWheelAddPoolWhite($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘删除奖池白名单
    public function wishWheelDelPoolWhite(Request $request){
        $res = $this->model->wishWheelDelPoolWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘删除奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘取消投放奖池白名单
    public function wishWheelCancelPoolWhite(Request $request){
        $res = $this->model->wishWheelCancelPoolWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘取消投放奖池白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池白名单列表
    public function wishWheelPoolWhiteList(Request $request){
        $res = $this->model->wishWheelPoolWhiteList($request, $this->user);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘个人池奖池列表
    public function wishWheelUserPoolList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->wishWheelUserPoolList($request));
    }

    //许愿转盘更新进入个人池配置
    public function wishWheelSetInUserPoolConfig(Request $request){
        $res = $this->model->wishWheelSetInUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘更新进入个人池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘更新离开个人池配置
    public function wishWheelSetOutUserPoolConfig(Request $request){
        $res = $this->model->wishWheelSetOutUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘更新离开个人池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘个人池汇总数据
    public function wishWheelUserPoolStat(Request $request){
        $res = $this->model->wishWheelUserPoolStat($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘奖池更新阀值
    public function wishWheelSetUserPoolConfig(Request $request){
        $res = $this->model->wishWheelSetUserPoolConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘奖池更新阀值');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增抽取奖池
    public function wishWheelAddExtractPool(Request $request){
        $res = $this->model->wishWheelAddExtractPool($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增抽取奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘编辑抽取奖池
    public function wishWheelEditExtractPool(Request $request){
        $res = $this->model->wishWheelEditExtractPool($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘编辑抽取奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘设置抽取奖池开启/关闭
    public function wishWheelSetExtractPoolStatus(Request $request){
        $res = $this->model->wishWheelSetExtractPoolStatus($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘设置抽取奖池开启/关闭');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增抽取奖池用户
    public function wishWheelAddExtractPoolUser(Request $request){
        $res = $this->model->wishWheelAddExtractPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增抽取奖池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘删除抽取奖池用户
    public function wishWheelDelExtractPoolUser(Request $request){
        $res = $this->model->wishWheelDelExtractPoolUser($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘删除抽取奖池用户');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘新增抽取奖池礼物
    public function wishWheelAddExtractPoolGift(Request $request){
        $res = $this->model->wishWheelAddExtractPoolGift($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '许愿转盘新增抽取奖池礼物');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽取奖池剩余数量
    public function wishWheelPoolExtractLessNum(Request $request){
        $res = $this->model->wishWheelPoolExtractLessNum($request->all());

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽取奖池列表
    public function wishWheelExtractPoolList(Request $request){
        $res = $this->model->wishWheelExtractPoolList($request);

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽取奖池日志列表
    public function wishWheelExtractPoolLogList(Request $request){
        $res = $this->model->wishWheelExtractPoolLogList($request);

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //许愿转盘抽取奖池用户列表
    public function wishWheelExtractPoolUserList(Request $request){
        $res = $this->model->wishWheelExtractPoolUserList($request);

        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }


}
